//-----------------------------------------------------------------------------
// ShTypedUtilities
//
// Copyright (c) MetaSwitch 2006
//
// This file provides utilities to those example applications that use the
// "typed" WSDL file and therefore deal with user data as Java classes.
//-----------------------------------------------------------------------------

import java.util.*;

import com.MetaSwitch.EMS.SOAP.*;

public class ShTypedUtilities extends ShUtilities
{
  /**
   * Finds the current sequence number within the user data and increments it,
   * wrapping if necessary, so that the server accepts the change.
   *
   * @param userData    IN/OUT The user data whose sequence number to update.
   */
  public void incrementSequenceNumber(TUserData userData)
  {
    TTransparentData repositoryData = userData.getShData().getRepositoryData();

    int newSequenceNumber = repositoryData.getSequenceNumber() + 1;

    if (newSequenceNumber > 65535)
    {
      //-----------------------------------------------------------------------
      // The sequence number needs to wrap to 1, not 0: 0 is used to create
      // new objects.
      //-----------------------------------------------------------------------
      newSequenceNumber = 1;
    }

    repositoryData.setSequenceNumber(newSequenceNumber);
  }
}
